package ace.module.stock.core.impl.controller.rest.rpc.ext;

import ace.cmp.core.model.R;
import ace.cmp.security.oauth2.resource.server.core.annotation.PreAuthorizeIsInternalClient;
import ace.module.common.api.model.input.TenantAndAppTypeInput;
import ace.module.stock.api.model.dto.ext.WmsStockAndSalesQuantityDto;
import ace.module.stock.api.model.input.WmsBizInitInput;
import ace.module.stock.api.model.input.WmsBizParentIdInput;
import ace.module.stock.api.model.input.WmsBizUniqueIdInput;
import ace.module.stock.core.impl.service.WmsStockAndSalesQuantityService;
import ace.module.stock.sdk.core.feign.impl.WmsStockAndSalesQuantityFeign;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * rpc controller.
 *
 * @author Caspar
 */
@Tag(name = "库存与乐理-RPC-API")
@PreAuthorizeIsInternalClient
@AllArgsConstructor
@RestController
@RequestMapping(WmsStockAndSalesQuantityFeign.PATH)
public class WmsStockAndSalesQuantityRpcController
    implements WmsStockAndSalesQuantityFeign {

  private final WmsStockAndSalesQuantityService wmsStockAndSalesQuantityService;

  @Override
  public R<Void> initOrSetStockAndInitSalesQuantity(TenantAndAppTypeInput<WmsBizInitInput> input) {
    wmsStockAndSalesQuantityService.initOrSetStockAndInitOrNoneSalesQuantity(input);
    return R.ok();
  }

  @Override
  public R<List<WmsStockAndSalesQuantityDto>> getByBizUniqueIdIn(TenantAndAppTypeInput<List<WmsBizUniqueIdInput>> bizUniqueIds) {
    List<WmsStockAndSalesQuantityDto> result = this.wmsStockAndSalesQuantityService.getDtoByBizUniqueIdIn(bizUniqueIds);
    return R.ok(result);
  }

  @Override
  public R<List<WmsStockAndSalesQuantityDto>> getByBizParentIdIn(TenantAndAppTypeInput<WmsBizParentIdInput> bizParentId) {
    List<WmsStockAndSalesQuantityDto> result = this.wmsStockAndSalesQuantityService.getDtoByBizParentIdIn(bizParentId);
    return R.ok(result);
  }
}